package com.wsl.tibet_sprcifcation.contorller;

import com.dym.util.Result;
import com.wsl.pojo.Tb_item_cat;
import com.wsl.service.Tb_item_catService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/itemcat")
public class Tb_item_catController {
    @Autowired
    private Tb_item_catService tb_item_catService;

    //一级菜单 默认是0
    @RequestMapping("/finditemcat/{id}")
    public List<Tb_item_cat> findallitemcat(@PathVariable("id") Integer id) {
        try {
            if (id == null) {
                id = 0;
                return tb_item_catService.findallitemcat(id);
            } else {
                return tb_item_catService.findallitemcat(id);
            }
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    @RequestMapping("/deleteById/{id}")
    public Result deleteById(@PathVariable("id") Long id){
                try {
                    tb_item_catService.deletetem(id);
                    return new Result(true,"删除成功");
                }catch (Exception ex){
                    ex.printStackTrace();
                    return new Result(false,"删除失败");
                }
    }
}

